package com.example.backend.controller;

import com.example.backend.common.ResultMessage;
import com.example.backend.entity.User;
import com.example.backend.service.IUserService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/usm")
public class UserController {

    @Resource(name = "userService")
    private IUserService userService;

    @GetMapping("/user")
    public ResultMessage<List<User>> selectUser() {
        try {
            List<User> userList = userService.selectUser();
            return ResultMessage.success(userList);
        } catch (Exception e) {
            return ResultMessage.error(500, "Internal server error");
        }
    }

}
